package com.dnw.shyfunny;

import android.widget.ListView;
import android.widget.TextView;

import com.dnw.adapter.ProgramAdapter;
import com.dnw.base.BaseActivity;
import com.dnw.modle.Program;
import com.dnw.modle.Result;
import com.dnw.presenter.ProgramPresenter;
import com.dnw.util.UIUtils;
import com.dnw.view.IProgramView;

import java.util.List;

import butterknife.Bind;
import butterknife.OnClick;
import flyn.Eyes;

/**
 * Created by yangyu on 2017/11/16.
 * 羞羞的应用
 */

public class ProgramActivity extends BaseActivity<ProgramPresenter> implements IProgramView {
    @Bind(R.id.tv_author)
    TextView tvAuthor;

    @Bind(R.id.lv_program)
    ListView lvProgram;

    ProgramAdapter mProgramAdapter;

    @Override
    public void initView() {
        Eyes.setStatusBarColor(this, UIUtils.getColor(R.color.a));
    }

    @Override
    public void initData() {
        tvAuthor.setText(getResources().getString(R.string.side_column_program));
        mPresenter.getProgramResult();
    }

    @Override
    protected ProgramPresenter createPresenter() {
        return new ProgramPresenter(this);
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_program;
    }

    @OnClick(R.id.tv_back)
    public void onViewClicked() {
        finish();
    }

    @Override
    public void onGetProgramSuccess(Result<List<Program>> result) {
        mProgramAdapter = new ProgramAdapter(getCurrentActivity(), result.data);
        lvProgram.setAdapter(mProgramAdapter);
    }

    @Override
    public void onError() {

    }
}
